package org.Leetcode;

public class E06Leetcode242 {
    public boolean isAnagram(String s, String t) {
        int length = s.length();
        if(length != t.length()){
            return false;
        }

        int[] nums = new int[26];
        for(char a : s.toCharArray()){
            int index = a - 'a';
            nums[index] ++;
        }

        for(char a : t.toCharArray()){
            int index = a - 'a';
            if(--nums[index] < 0){
                return false;
            };
        }
        return true;
    }
}
